/********************************************************************
 * PROJECT: CSAIR ROST PROJECT.
 * SUPPLIER: FOREVER OPEN SOURCE SOFTWARE INC.
 ********************************************************************
 * FILE: GanttMeasure.java
 * (C) Copyright Foliage Team 2013, All Rights Reserved.
 ********************************************************************/
package org.foliage.rcp.ui.preference;

import java.util.Calendar;

@SuppressWarnings("rawtypes")
public class GanttMeasure implements Comparable {

	// ----------------------------------------------- 

	private int unit;

	private int unitCount;

	private String dateFormat;

	private int align;

	// ----------------------------------------------- 

	public GanttMeasure() {}

	public GanttMeasure(int unit, int unitCount, String dateFormat, int align) {
		this.unit = unit;
		this.unitCount = unitCount;
		this.dateFormat = dateFormat;
		this.align = align;
	}

	// ----------------------------------------------- 

	public long getTimeInterval() {
		long interval = 0;
		switch (unit) {
		case Calendar.MINUTE:
			interval = 1000 * 60 * unitCount;
			break;
		case Calendar.HOUR_OF_DAY:
			interval = 1000 * 60 * 60 * unitCount;
			break;
		case Calendar.DAY_OF_MONTH:
			interval = 1000 * 60 * 60 * 24 * unitCount;
			break;
		}
		return interval;
	}

	// ----------------------------------------------- 

	public int getUnit() {
		return unit;
	}

	public void setUnit(int unit) {
		this.unit = unit;
	}

	public int getUnitCount() {
		return unitCount;
	}

	public void setUnitCount(int unitCount) {
		this.unitCount = unitCount;
	}

	public String getDateFormat() {
		return dateFormat;
	}

	public void setDateFormat(String dateFormat) {
		this.dateFormat = dateFormat;
	}

	public int getAlign() {
		return align;
	}

	public void setAlign(int align) {
		this.align = align;
	}

	@Override
	public int compareTo(Object obj) {
		GanttMeasure ganttMeasure = (GanttMeasure) obj;
		return (int) (getTimeInterval() - ganttMeasure.getTimeInterval());
	}

}
